package com.example.springboot02amqp.controller;

import com.alibaba.excel.EasyExcel;
import com.example.springboot02amqp.dao.AddressDao;
import com.example.springboot02amqp.listener.AddressListener;
import com.example.springboot02amqp.vo.AddressExcelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: 喵喵~
 * Date: 2023/2/10
 * Time: 1:46
 * Description:
 */
@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    AddressDao addressDao;
    @PostMapping("/upload")
    @ResponseBody
    public String upload(MultipartFile file) throws IOException {
        EasyExcel.read(file.getInputStream(), AddressExcelVO.class, new AddressListener(addressDao)).sheet().doRead();
        return "success";
    }
}
